﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data.OleDb;
using System.Data;

public partial class detail : System.Web.UI.Page
{
    public string swfPath = "";
    public string str;
    public int tjbId;
    public int grjjId;
    public int jxxdId;
    public int hjzsId;
    public int jylwId;
    public int cbjcId;
    public int kycgId;
    public int fmzlId;
    public int lxfsId;
    public int xmclId;
    public int kylwId;
    public string n_category;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GetData();
            tjbId = GetTopId("推荐表");
            grjjId = GetTopId("个人简介");
            jxxdId = GetTopId("教学心得");
            hjzsId = GetTopId("获奖证书");
            jylwId = GetTopId("教研论文");
            cbjcId = GetTopId("出版教材");
            kycgId = GetTopId("科研成果");
            fmzlId = GetTopId("发明专利");
            lxfsId = GetTopId("联系方式");
            xmclId = GetTopId("项目材料");
            kylwId = GetTopId("科研论文");
        }
        
    }
      //绑定新闻信息
    public void GetData()
    {
        if (!string.IsNullOrEmpty(Request.QueryString["n_id"]))
        {
            if (Request.QueryString["n_id"] == "111111")
            {
                Response.Write("<script>alert('暂无资料');window.top.location='index.aspx';</script>");
            }
            else
            {
                string selectSql = "select n_ppt,n_category from tb_News where n_id=@n_id";
                OleDbParameter[] para = {
                                    new OleDbParameter("@n_id",Request.QueryString["n_id"].ToString())
                                };
                DataTable dt = new DataTable();
                dt = OleDbHelper.GetDataTable(selectSql, para);
                string n_ppt = dt.Rows[0]["n_ppt"].ToString();
                n_category = dt.Rows[0]["n_category"].ToString();
                str = n_ppt;
                string Extens = Path.GetExtension(str.ToString());
                swfPath = str.ToString().Replace(Extens, ".swf");
            }
        }
        else
        {
            Response.Redirect("index.aspx");
        }
       
    }

    //取出一条最新数据GetTopId
    protected int GetTopId(string category)
    {
        int TopId = 1;
        string sqlSelect = "select top 1 n_id from tb_News where n_category=@category";
        OleDbParameter[] para = {
                                    new OleDbParameter("@category",category)
                                };
        OleDbDataReader dr = OleDbHelper.GetDataReader(sqlSelect, para);
        if (dr.HasRows)
        {
            if (dr.Read())
            {
                TopId = Convert.ToInt32(dr["n_id"].ToString().Trim());
            }
            dr.Close();
            dr.Dispose();
        }
        else
        {
            TopId = 111111;
            //Response.Write("<script>alert('暂无资料');window.top.location='index.aspx';</script>");
        }
        return TopId;
    }
}